-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Button groups in Typography tools should use ToggleGroupControl #64529
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
It basically works fine, but there are a few things I think need to be addressed.
The labels are not aligned when placed next to a 40px item:
This is the effect of the padding here:
padding: $grid-unit-05 0; |
We can remove the following custom styles:
gutenberg/packages/block-editor/src/components/segmented-text-control/style.scss
Lines 6 to 14 in cb224d4
.block-editor-segmented-text-control__buttons { | |
// 4px of padding makes the row 40px high, same as an input. | |
padding: $grid-unit-05 0; | |
display: flex; | |
} | |
.components-button.has-icon { | |
margin-right: $grid-unit-05; | |
} |
Additionally, if we just remove this style, the horizontal alignment of the 40px sized text field and button will not match:
This problem can be solved by adding __next40pxDefaultSize
to the ToggleGroupControl
component.
Thanks @t-hamano, I would update the PR asap with the requested changes. |
While testing this PR, I noticed that when
I don't know if this is a bug or expected behavior, but I'll send a ping to the @WordPress/gutenberg-components team. e34b1b640ceb395431711773de264e8e.mp4 |
Thanks for the ping! Yes, this is intended behavior. Enabling Though there have been some discussions to change the visual design more substantially (#64439), so it would cause less confusion around it. |
/> | ||
); | ||
} ) } | ||
</ToggleGroupControl> | ||
</div> | ||
</fieldset> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ToggleGroupControl usage looks good, thank you!
However, the outer fieldset
and div
are now completely unnecessary, and this SegmentedTextControl
component is also unnecessary, as consumers can just use ToggleGroupControl
directly. There is nothing that this component adds on top of ToggleGroupControl itself.
Ideally, we would clean that up in this PR, but if you prefer, we can split out the refactoring work to a separate PR. At minimum, I think we should to remove the fieldset
and div
before landing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can update on this PR itself, let me know what suits better. I am open to both.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably better to have those updates as part of this PR, if you don't mind. Thank you 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SegmentedTextControl
component is a wrapper component introduced in #60841 to make the same code common.
We should be able to simply replace the SegmentedTextControl
component with the ToggleGroupControl
component.
Also, since the SegmentControl
component is not exposed, it is safe to delete it 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Team, apologies, I would be updating these feedbacks by tomorrow. ✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@t-hamano Sorry, I misinterpreted this part. Focus loss is indeed strange, and I can't repro on the major three browsers on Mac. Could it be a Windows thing? It's supposed to move through the options with Tab, but arrow keys shouldn't cause focus loss. Or do you have some kind of special mode enabled? I noticed in your screen recording that the arrow key moved a text cursor into the label 😳 I've never seen that before. |
After researching this problem, I found that it has to do with the "text cursor mode" of the Chrome browser: Use a text cursor to navigate and select text - Google Accessibility Help This means that we can move text with the left and right keys regardless of whether the element is focusable or not. I assumed that this behavior was the default behavior of the Windows OS, but it seems to be a Chrome-specific feature 😅 This feature can be disabled with the F7 key. So what I mentioned may not be a bug. 81445d75b947d5174259f4776daf8ab3.mp4 |
Interesting 😳 Thanks for looking into it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just gave this a round of testing, and it works/looks great!
Not much to add to the prior feedback, but I just wanted to thank you @hbhalodia for the great work utilizing the right @wordpress/components
and cleaning up unnecessary deviation 🚀
Absolutely! Thank you @hbhalodia for your great work. It would be great to continue the collaboration, in case you had more capacity! Code is looking good on my end, but I'll let @t-hamano and @mirka give the final approval as they've been reviewing the PR from the start. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful, thank you for the cleanup! 🚀
@hbhalodia Thank you for your great work! |
What?
Why?
How?
SegmentedTextControl
component, to make use ofToggleGroupControl
andToggleGroupControlOptionIcon
to render the same logic as it did with buttons.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast